package com.hundred.item.module.screen;

import java.util.List;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.Navigator;
import com.alibaba.citrus.util.StringUtil;
import com.hundred.item.dao.dataobject.ItemDO;
import com.hundred.item.manager.ItemCompareManager;
import com.hundred.item.manager.ItemManager;

public class SelectCompareItems {

	private static final Logger logger = LoggerFactory.getLogger(SelectCompareItems.class);

	@Autowired
    private HttpServletRequest request;
	@Autowired
	private ItemManager itemManager;
	@Autowired
	private ItemCompareManager itemCompareManager;
	
	public void execute(Context context, Navigator nav) {
		
		
		String tagStr = request.getParameter("tag");
		int tag = 100;
		if(!StringUtil.isBlank(tagStr)){
			tag=Integer.parseInt(tagStr);
		}
		
		logger.error("用户选择标签："+tag);
		
		List<ItemDO> itemList = itemCompareManager.selectCompareItems(2,tag);
		
		context.put("leftItem", itemList.get(0));
		
		context.put("rightItem", itemList.get(1));
		
	}

	
	public ItemManager getItemManager() {
		return itemManager;
	}

	public void setItemManager(ItemManager itemManager) {
		this.itemManager = itemManager;
	}


	public ItemCompareManager getItemCompareManager() {
		return itemCompareManager;
	}


	public void setItemCompareManager(ItemCompareManager itemCompareManager) {
		this.itemCompareManager = itemCompareManager;
	}
}
